"""合并两个.txt文件的内容，把一个文件的内容追加写入另一个文件的尾部。"""

def mergeTxt(txtFiles):
    with open(txtFiles[0], 'a', encoding='utf-8') as f1, open(txtFiles[1], 'r', encoding='utf-8') as f2:
        f1.write('\n')
        for i in f2:
            f1.write(i)
        print('已成功将文档2的内容追加到文档1的后面！')


if __name__ == "__main__":
    txtFiles = [r'resources\1.txt', r'resources\2.txt']
    mergeTxt(txtFiles)
    # 从文本文件中读取一行
    with open(txtFiles[0], "r", encoding='utf-8') as f1:
        first_line = f1.readline()
        print("第一行是：" + first_line)
    # 读取文本文件中所有行
    f1 = open(txtFiles[0], 'r', encoding='utf-8')
    file_list = f1.readlines()
    print(file_list)
